﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title></title>
</head>
<body>

<p>Q: How do I go about debugging Gestalt application?

<p>A: One convenient way to debug exceptions that are raised while you are developing your application is to add the System.Diagnostics namespace to your Python or Ruby code. In Python the syntax is:

<pre>from System.Diagnostic import *</pre>

<p>In Ruby the syntax is: </p>

<pre>require System::Diagnostic</pre>

<p>Then inline the following in your Python functions or classes. You can make a call to the Debug.Writeline() method which takes a string as a parameter:

<pre>Debug.WriteLine(“hello debug!”)

-or-

Debug.WriteLine( <em>classInstance.aProperty</em>.ToString() ) # this will cast whatever object type the aProperty is to a string</pre>
<p>In Ruby, it’s the same:

<pre>Debug.WriteLine(“hello debug!”)

-or-

Debug.WriteLine( <em>classInstance.aProperty</em>.ToString() ) # this will cast whatever object type the aProperty is to a string</pre>

It is also usefull to know about the try: except statement in Python. Use it in this form inline in code. This writes the error message associated with the failed line of code to a debug window. DebugView is one tool that allows you to view debug messages.
<pre>import sys
try:
   <em>some code that might fail</em>
except:
   Debug.WriteLine(sys.exc_info())</pre>

<p>In Ruby do the following:(TODO?)

<pre>require "sys"
try:
   <em>some code that might fail</em>
except:
   Debug.WriteLine(sys.exc_info())</pre>
  
<p>You may find that background threads tend to swallow exceptions, such as a 
    Storyboard_Completed event. You can add a try: except to any code in these and 
    it will surface an errors that occur.

</body>
</html>
